﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TSCC.WinApp
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbConnection cnn = new System.Data.OleDb.OleDbConnection();
            //cnn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\VS2010B2\TSCCApp\bin\Data\EL.mdb;Password=TSCC;";
            cnn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\VS2010B2\TSCCApp\bin\Data\EL.mdb;Persist Security Info=True;Jet OLEDB:Database Password=TSCC";
            //cnn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MY\WORK\CIB\企金.mdb;User Id=admin;Password=;";
            cnn.Open();
            IDbCommand cmd = cnn.CreateCommand();
            //System.Data.OleDb.OleDbCommand cmd = cnn.CreateCommand();
            //cmd.CommandText = "SELECT * FROM [Exception]";
            IDbDataParameter para1 = cmd.CreateParameter();
            para1.DbType = DbType.String;
            para1.Value = "23456";
            para1.ParameterName = "V1";

            IDbDataParameter para2 = cmd.CreateParameter();
            para2.DbType = DbType.String;
            para2.Value = "123456";
            para2.ParameterName = "V2";
            cmd.Parameters.Add(para1);
            cmd.Parameters.Add(para2);


            cmd.CommandText = @"SELECT Manager.PW, CSREmployee.姓名, CSREmployee.組別, CSREmployee.員編
                                    FROM CSREmployee LEFT JOIN Manager ON CSREmployee.員編 = Manager.員編
                                    WHERE CSREmployee.員編 in( @V1,@V2) ;";

            System.Data.OleDb.OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) as System.Data.OleDb.OleDbDataReader;
            DataTable dt = new DataTable();
            dt.Load(dr);
            MessageBox.Show(dt.Rows.Count.ToString());
        }
    }
}
